package com.hanamaki.oop.demo09;

public class Application {

    public static void main(String[] args) {

//        实例化子类 student
        Object o = new Student();

//         使用 instanceof 来判断 两个类之间是否存在父子关系
        System.out.println(o instanceof Student);// true
        System.out.println(o instanceof Person); // true
        System.out.println(o instanceof Object); // true
        System.out.println(o instanceof Teacher);// false
        System.out.println(o instanceof String); // false

        System.out.println("===================");

        Person p = new Student();
        System.out.println(p instanceof Student);// true
        System.out.println(p instanceof Person); // true
        System.out.println(p instanceof Object); // true
        System.out.println(p instanceof Teacher);// false
//        System.out.println(p instanceof String); //  编译报错

        System.out.println("=======================");

        Student s = new Student();
        System.out.println(s instanceof Student);// true
        System.out.println(s instanceof Person); // true
        System.out.println(s instanceof Object); // true
//        System.out.println(s instanceof Teacher);// 编译报错
//        System.out.println(s instanceof String); // 编译报错

    }
}
